package com.zhanggm.springcloud.user.controller;

import com.zhanggm.springcloud.user.pojo.User;
import com.zhanggm.springcloud.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/user/")
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${server.port}")
    private Integer serverPort;

    /**
     * 查询用户
     * @param id
     * @return
     */
    @RequestMapping("getUserById")
    public User getUserById(@RequestParam("id") Integer id){
        log.info("server.port:{}",serverPort);
        return userService.getUserById(id);
    }

    /**
     * 查询用户名称
     * @param id
     * @return
     */
    @RequestMapping("getUsernameById")
    public String getUsernameByI(@RequestParam("id") Integer id){
        return userService.getUsernameById(id);
    }

}
